#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;

const int MAXN=3e5+10;
long long t, n, m, l, mxv;
long long d[MAXN], v[MAXN], a[MAXN], p[MAXN];
long long crn, drn;

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);

    cin>>t;
    for (int ddd=0;ddd<t;ddd++){
        crn=0; drn=0;
        memset(d, 0, sizeof(d));
        memset(v, 0, sizeof(v));
        memset(a, 0, sizeof(a));
        cin>>n>>m>>l>>mxv;
        for (int i=0;i<n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for (int i=0;i<m;i++){
            cin>>p[i];
        }
        for (int i=0;i<n;i++){
            int flg=0;
            int j; j=m-1;
                if (p[j]<d[i]) continue;
                double tv;
                tv=sqrt(pow(v[i], 2)+2.0*a[i]*(p[j]-d[i]));
                if (tv>mxv){
                    flg=1;
                }
            crn+=flg;
        }
        if (crn) drn=m-1;
        else drn=m;
        cout<<crn<<" "<<drn<<endl;
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}
